package VendingMachine;
import static org.junit.Assert.*;
import junit.framework.TestCase;
 
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


	 
	 public class VendingMachineItemTest extends TestCase  {
		 VendingMachineItem test1=null;
         VendingMachineItem test2=null;
		
         
         
         @Before
         public void setUp() throws Exception {
         test1 = new VendingMachineItem( "chocolate",2.99);
         test2 = new VendingMachineItem( "biscuit",1.99);
         }
  
         @After
         public void tearDown() throws Exception {
         test1 = null;
         test2 = null;
         } 
         
         public void testgetName(){ 
        	 Assert.assertTrue("chocolate".equals(test1.getName()));
        	 Assert.assertTrue("biscuit".equals(test2.getName()));
         }
         public void testgetPrice(){
        	 assertEquals(2.99, test1.getPrice(),0.001);
        	 assertEquals(1.99, test2.getPrice(),0.001);
        	 
         }
         
         public void testPriceBelowZero(){         	
            try{
        	@SuppressWarnings("unused")
			VendingMachineItem test3 = new VendingMachineItem( "bar", -1.00); }  
            catch(VendingMachineException test3){
            assertEquals(test3.getMessage(), "Price cannot be less than zero"); }
          }
         
         public void testInvalidName(){
        	 VendingMachineItem test4 = new VendingMachineItem( null, 10.00);
        	 assertEquals(null, test4.getName());
         }
	 } 



